@isTest
private class TestSearchPageController {

	/****Condition where the search returns result****/
    static testMethod void searchFound() {
    	/*Creating test data*/
    	West_Case_Names__c testCaseNames = TestDatabaseCMS.createWestCaseNames();
    	Lead testLead = TestDatabaseCMS.createLeadForTesting();
    	Account testAccount = TestDatabaseCMS.createAccountForTesting();
    	
    	/*testing*/
    	test.startTest();
    	
    	SearchPageController_AC searchController = new SearchPageController_AC(new ApexPages.StandardController(testAccount));
    	
    	searchController.reset();
    	
    	searchController.fname = 'Create';
    	searchController.lname = 'Test';
    	
    	searchController.search();
    	
    	searchController.email = 'abcd1@ddd.com';
    	searchController.search();
    	
    	searchController.getShowResultsBlock();
    	searchController.getpbtitleValue();
    	searchController.getpbsectitleValue();
    	searchController.getsearchButtonEnable();
    	
    	searchController.searchButtonEnable=false;
    	searchController.getpbtitleValue();
    	searchController.getpbsectitleValue();

    	test.stopTest();
    	
    	/*Asserting correctness*/
    	system.assert(searchController.getcatchAccounts().size()>0);
   
    }
    
    /****Conditions where all the field checks are covered ****/
    static testMethod void fieldChecks() {
    	/*Creating test data*/
    	West_Case_Names__c testCaseNames = TestDatabaseCMS.createWestCaseNames();
    	Lead testLead = TestDatabaseCMS.createLeadForTesting();
    	Account testAccount = TestDatabaseCMS.createAccountForTesting();
    	
    	/*testing*/
    	test.startTest();
    	
    	SearchPageController_AC searchController = new SearchPageController_AC(new ApexPages.StandardController(testAccount));
    	
    	searchController.fname = '';
    	searchController.lname = '';
    	searchController.email = '';
    	searchController.phoneNum = '';
    	searchController.search();
    	
    	searchController.fname = 'Create&';
    	searchController.lname = 'Test%';
    	searchController.search();
    	
    	searchController.fname = 'Create';
    	searchController.lname = 'Test';
    	searchController.email = 'dddd.com';
    	searchController.search();
    	
    	searchController.email = 'sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss@yyyyyyyyyyyyy.com';
		searchController.search();
		
		searchController.email = '';
		searchController.phoneNum='999333449';
		searchController.search();
		
		searchController.phoneNum='5678s04356';
		searchController.search();
		
		searchController.phoneNum='5678904356';
		searchController.search();
		
    	test.stopTest();
    }
    
    /****Condition where new Lead is created ****/
    static testMethod void newLeadCreated() {
    	/*Creating test data*/
    	West_Case_Names__c testCaseNames = TestDatabaseCMS.createWestCaseNames();
    	Lead testLead = TestDatabaseCMS.createLeadForTesting();
    	Account testAccount = TestDatabaseCMS.createAccountForTesting();
    	
    	/*testing*/
    	test.startTest();
    	
    	SearchPageController_AC searchController = new SearchPageController_AC(new ApexPages.StandardController(testAccount));
    	searchController.reset();
    	
    	searchController.fname = 'xx';
    	searchController.lname = 'Texxst';
    	searchController.search();
    	
    	searchController.lname = '';
    	searchController.email = '';
    	searchController.state = 'AZ';
    	searchController.country = 'USA';
    	searchController.saveButtonClicked();
    	
    	searchController.fname = 'Create&';
    	searchController.lname = 'Test%';
    	searchController.saveButtonClicked();
    	
    	searchController.fname = 'Create';
    	searchController.lname = 'Test';
    	searchController.email = 'dddd.com';
    	searchController.saveButtonClicked();
    	
    	searchController.email = 'sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss@yyyyyyyyyyyyy.com';
		searchController.saveButtonClicked();
		
		searchController.email = 'correcttest@em.com';
		searchController.phoneNum='999333449';
		searchController.saveButtonClicked();
		
		searchController.phoneNum='5678s04356';
		searchController.saveButtonClicked();
		
		searchController.phoneNum='5678904356';
		searchController.saveButtonClicked();
		
		searchController.state = 'AZ3';
		searchController.saveButtonClicked();
		
		searchController.state = 'AZ';
		searchController.country = 'USAs3';
    	searchController.saveButtonClicked();
    	
    	
    	searchController.fname = 'xx';
    	searchController.lname = 'Texxst';
    	searchController.email = 'correcttest@em.com';
    	searchController.state = 'AZ';
    	searchController.country = 'USA';
    	searchController.saveButtonClicked(); 
    	
    	
    	searchController.newAccButtonClicked();
    	searchController.clickResultLink();

    	test.stopTest();
   
    }
}